home *** CD-ROM | disk | FTP | other *** search
/ Draw & Design / Draw & Design.iso / DESIGN / DES_PS.PRE < prev    next >
Text File  |  1993-01-04  |  28KB  |  1,095 lines

  1. %-----------------------------------------------------------------------------
  2. % 9999.17 GST 194 - PostScript Preamble file for GST DesignWorks
  3. %-----------------------------------------------------------------------------
  4. % This file is inserted as the prolog when Artwork saves an EPSF file.
  5. % The program generates the initial structure comments required by EPSF
  6. % and strips comments from this file as it merges it into its output.
  7. % The main part of the job is put between the 'EndSetup' and 'Trailer' lines.
  8. %-----------------------------------------------------------------------------
  9. % Naming conventions: 
  10. % Names in all lowercase are executable procedures, like built-in postscript
  11. % procedures. Names with the first letter capitalised are variables. Names 
  12. % ending in a question mark are boolean: they can have values T or F
  13. %-----------------------------------------------------------------------------
  14. % version 0.24 4/1/93
  15. % NOTE: comments are stripped before printing!
  16. %-----------------------------------------------------------------------------
  17. %
  18. % ArtProcsDict contains all the procedures defined in this prolog
  19. % and must also have enough room for special postscript fill & line style procs.
  20. % ArtVarsDict contains all the variables etc used by the procedures.
  21.  
  22. /ArtProcsDict 160 dict def  
  23. /ArtVarsDict 100 dict def  
  24.  
  25. %---- optional jobtimeout 
  26. ArtVarsDict begin 
  27.    /Timeout 0 def 
  28. end
  29.  
  30. ArtProcsDict begin
  31.  
  32. %----- abbreviations -----%
  33.  
  34.  /bd { bind def } bind def
  35.  /ed { exch def } bd
  36.  /np /newpath load def
  37.  /cp /closepath load def
  38.  /gs { /SavePrint? Print? def gsave } bd
  39.  /gr { /Print? SavePrint? def grestore } bd
  40.  
  41.  /SS{}def
  42.  /RS{}def
  43.  /SM{}def
  44.  
  45. %----- misc tiny routines -----%
  46.  
  47. % specialscreen? returns YES if screen frequency <= 30
  48.  /specialscreen? { currentscreen pop pop 30 lt } bd
  49.  /min{2 copy gt{exch}if pop}bd % minimum of top 2 items on stack
  50.  /max{2 copy lt{exch}if pop}bd % maximum ditto
  51.  /maxof4 { 3{max}repeat } bd
  52.  /pt { 1000 mul 72 div } bd % converts points
  53.  /beginlayer { pop /LayerSave save def } bd %% layer number ignored
  54.  /endlayer { LayerSave restore } bd
  55.  
  56.  
  57. %----- path construction -----%
  58.  
  59. % P: adjusts positions of thin lines 
  60.  /p { transform round .4 add exch round .4 add exch itransform } bd
  61.  /c { p curveto } bd /m { p moveto } bd /l { p lineto } bd
  62.         
  63.  
  64. %---------- Colour handling ----------%
  65. %
  66. % define setcmykcolor if not implemented in printer. 
  67.  
  68. /mysetcmykcolor { % convert CMYK to RGB for monochrome printer
  69.   4 1 roll
  70.   3 {
  71.     3 index add 1 exch sub
  72.     dup 0 lt{pop 0}if
  73.     3 1 roll
  74.   } repeat
  75.   setrgbcolor pop
  76. } bd
  77.  
  78. /initcmykcolor {
  79.   /setcmykcolor where dup
  80.   /BwPrinter? exch not def
  81.   { 
  82.     pop 
  83.   }{
  84.     /setcmykcolor /mysetcmykcolor load def
  85.   } ifelse
  86. } bd
  87.  
  88.  
  89. %----- SETCMYK -----%
  90. % setcmyk is a low-level routine, called whether or not the 
  91. % printer supports colour.
  92. % It is at this level that we perform process colour separation.
  93. % We save the current CMYK setting, and routine currentcmyk can
  94. % be called to enquire the setting.
  95.  
  96. /setcmyk { 
  97.   4 copy SaveCmyk astore pop 
  98.   Comp? {               % printing a monochrome or colour composite
  99.     BwPrinter? specialscreen? and
  100.     {
  101.         % printing a special screen on a monochrome composite
  102.         % don't convert cmyk, as we'll end up with stripes or dots
  103.         % which are too small: convert the largest process colour
  104.         % component to gray. (Still not completely correct)
  105.         maxof4 1 exch sub setgray
  106.     }{
  107.       setcmykcolor 
  108.     } ifelse
  109.   }{
  110.     SpotSep? {          % if printing a spot-colour separation
  111.       blank pop         % print blank (clear or white, depending on overprint flag) 
  112.     }{                  % else printing a a process separation
  113.       4 Separation roll % bring one sep to top
  114.       dup 0 eq { 
  115.         blank pop 
  116.       }{ 
  117.         1 exch sub setgray 
  118.       } ifelse
  119.     } ifelse
  120.     pop pop pop         % clear c,m,y from stack
  121.   } ifelse
  122. } bd
  123.  
  124.  
  125. /currentcmyk {
  126.   SaveCmyk aload pop
  127. } bd
  128.  
  129.  
  130. %----- APPLYTINT -----%
  131. %
  132. % This is a lower-level colour interface
  133. % which can apply a percentage tint to a set
  134. % of CMYK percentage values.
  135. %
  136. % stack: t% c% m% y% k%
  137.  
  138. /applytint {
  139.   4{ 
  140.     4 index mul 
  141.     10000 div 
  142.     4 1 roll 
  143.   }repeat 
  144.   setcmyk 
  145.   pop 
  146. } bd
  147.  
  148.  
  149.  
  150. /blank { 
  151.   1 setgray 
  152.   /Print? OverPrint? not def 
  153.   0 0 0 0 SaveCmyk astore pop
  154. } bd
  155.  
  156.  
  157. /setgraytint {
  158.   dup 0 eq { OverPrint? not } { T } ifelse 
  159.   /Print? ed
  160.   dup /SpotTint ed
  161.   100 div 1 exch sub setgray
  162. } bd
  163.  
  164.  
  165. %----- COLPROCS -----%
  166. % Colprocs is a dictionary containing different procedures for 
  167. % setcolour to execute, depending on the type of the object 
  168. % on top of the stack when setcolour is called.
  169. % Colours is a dictionary of user-defined colours, indexed by name,
  170. % containing 2-level [ [C M Y K] spot? ] arrays with values in range 0-100
  171.  
  172. /Colprocs 4 dict def 
  173. Colprocs begin
  174.  
  175.   /arraytype {                          % [ C M Y K ] process colour mix
  176.       100 exch aload pop applytint      % apply 100% tint to the mix
  177.   } bd
  178.  
  179.   % perform spot-colour separation 
  180.   /nametype {                   % stack: tint name
  181.     dup Colours exch get        % tint name [ [ C M Y K ] Spot? ]
  182.     1 get not Comp? or {        % if not a spot colour, or printing composite
  183.       Colours exch get          % tint [ [ C M Y K ] Spot? ]
  184.       0 get aload pop           % tint c m y k
  185.       applytint 
  186.     }{                          % else spot colour & not composite printout
  187.       SpotSep? {                % if printing a spot separation...
  188.         Separation eq {            % is spot colour same as this separation?
  189.           setgraytint           % if so, set percentage tint
  190.         }{
  191.           pop blank             % wrong spot sep: print nothing
  192.         } ifelse
  193.       }{
  194.         pop pop blank           % printing a process sep: print nothing
  195.       } ifelse
  196.     } ifelse
  197.   } bd
  198.  
  199.   /integertype {                % apply percentage tint to black
  200.     0 0 0 100 applytint 
  201.   } bd
  202.  
  203.   /realtype /integertype load def
  204. end % Colprocs
  205.  
  206.  
  207.  
  208. %----- SETCOLOUR -----%
  209. %
  210. % This routine is the top-level color interface. 
  211. % It can be called in three different ways:
  212. %   number      SETCOLOUR --  % number is %black, 0=white 100=black
  213. %   [ 4-array ] SETCOLOUR --  % array contains C M Y K percentages
  214. %   number name SETCOLOUR --  % percentage tint of a named colour
  215.  
  216. /setcolour { 
  217.   /Print? T def
  218.   /SpotTint 0 def % preset spot colour tint value to zero
  219.   dup type Colprocs exch get exec 
  220. } bd
  221.  
  222.  
  223.  
  224. %----- FILL and STROKE -----%
  225. %
  226. % Winding? is a boolean which selects whether we use the winding-number fill
  227. % or the even-odd fill algorithm. Print? is a boolean used to enable or 
  228. % disable fill and stroke when overprinting separations, set by setcolour 
  229. % and blank.
  230.  
  231.  /ovp { /OverPrint? ed } bd
  232.  /wif { /Winding? T def } bd
  233.  /eof { /Winding? F def } bd
  234.  
  235.  /~stroke { Print? { stroke } if } bd
  236.  /_stroke { setcolour ~stroke } bd
  237.  /~fill { Print? { Winding? { fill } { eofill } ifelse } if } bd
  238.  /_fill { setcolour ~fill } bd
  239.  /_clip { Winding? { clip } { eoclip } ifelse } bd
  240.  
  241.  /sml { 2 div sin 1 exch div setmiterlimit } bd
  242.  /sline { setlinewidth setlinejoin setlinecap } bd
  243.  /li { Lines exch get exec } bd
  244.  /fi { Fills exch get exec } bd
  245.  
  246.  
  247.  
  248. %----- GROUPS -----%
  249.  
  250.  /bg { gsave concat } bd % matrix BG -- 
  251.  /eg { grestore } bd 
  252.  
  253.  
  254.  
  255. %----- Utility Routines -----%
  256.  
  257.  /getbox { /Top ed /Right ed /Bottom ed /Left ed } bd 
  258.  
  259.  /arcpop { arcto 4 { pop } repeat } bd
  260.  
  261.  
  262.  
  263. %----- basic shapes: ROUND BOX -----%
  264.  
  265. /shape_rbox {
  266.   /Rad ed
  267.   getbox
  268.   matrix currentmatrix
  269.     exch concat
  270.     np Left Right add 2 div Top p moveto % top centre
  271.     Right Top p Right Bottom p Rad arcpop
  272.     Right Bottom p Left Bottom p Rad arcpop
  273.     Left Bottom p Left Top p Rad arcpop
  274.     Left Top p Right Top p Rad arcpop cp 
  275.   setmatrix
  276. } bd
  277.  
  278.  
  279.  
  280. %----- basic shapes: BOX -----%
  281. /boxpath {
  282.   np Left Top m Right Top l
  283.   Right Bottom l Left Bottom l cp
  284. } bd
  285.  
  286. /shape_box {
  287.   getbox
  288.   matrix currentmatrix
  289.     exch concat boxpath
  290.   setmatrix
  291. } bd
  292.  
  293.  
  294. /clip_box { getbox boxpath eoclip } bd
  295.  
  296.  
  297.  
  298. %----- basic shapes: ELLIPSE -----%
  299.  
  300. /shape_ellipse {
  301.   getbox
  302.   matrix currentmatrix 
  303.     exch concat
  304.     % map unit circle to bounding box
  305.     Left Top translate
  306.     Right Left sub Bottom Top sub scale
  307.     np .5 .5 .5 0 360 arc cp
  308.   setmatrix
  309. } bd
  310.  
  311.  
  312. %----- IMAGES -----%
  313.  
  314. /artimage {
  315.   gs
  316.     /Bgd? exch def
  317.     /Mask? exch def
  318.     /Bits exch def 
  319.     /Height exch def
  320.     /Width exch def
  321.     getbox concat 
  322.  
  323.     Bgd? { setcolour boxpath wif ~fill } if
  324.  
  325.     Left Top translate 
  326.     Right Left sub 
  327.     Bottom Top sub scale
  328.  
  329.     Mask? {   
  330.       setcolour
  331.         Width Height true [ Width 0 0 Height 0 0 ] 
  332.         { currentfile ImageBuff readhexstring pop }
  333.       imagemask
  334.     }{  Width Height Bits [ Width 0 0 Height 0 0 ] 
  335.         { currentfile ImageBuff readhexstring pop }
  336.       image
  337.     } ifelse
  338.   gr
  339. } bd    
  340.  
  341.  
  342. /densitylookup {
  343.    densitygreys 1 sub mul cvi  % convert input grey level to integer
  344.    densityarray exch get   % lookup value (range 0..2000)
  345.    1000 div             % convert to density 0.0-2.0
  346.    neg 10 exch exp      % reflectance = 10 ^ -density
  347. } bd
  348.  
  349. /palettelookup {
  350.    palettecols 1 sub mul cvi  % convert input grey level to integer
  351.    palettearray exch get   % lookup value (range 0..1000)
  352.    1000 div             % convert to reflectance 0..1
  353. } bd
  354.  
  355. /artcolimage {
  356.   gs
  357.     /Proc exch load def 
  358.     /Height ed /Width ed
  359.     getbox concat            
  360.     Left Top translate 
  361.     Right Left sub 
  362.     Bottom Top sub scale
  363.  
  364.     /Im? T def
  365.     /Wn Width def
  366.  
  367.     Width Height 8 [ Width 0 0 Height 0 0 ] 
  368.     /Proc load 
  369.     false 3 colorimage
  370.  
  371.     gr
  372. } bd    
  373.  
  374. /img4 {
  375.  Im? {
  376.    % read one byte from the file
  377.    currentfile ImageBuff readhexstring pop 
  378.    0 get -4 bitshift
  379.  }{
  380.    ImageBuff 0 get
  381.  }ifelse
  382.  
  383.  %--- see if we're at the end of a raster line
  384.  Wn 1 sub dup 0 eq { pop Width T }{ Im? not } ifelse
  385.  /Im? ed /Wn ed
  386.  
  387.  % use result as index into palette
  388.  15 and palettearray exch get 
  389. } bd
  390.  
  391.  
  392. /img8 {
  393.    currentfile ImageBuff readhexstring pop % read one byte from the file
  394.    0 get palettearray exch get % use that as index into palette
  395. } bd
  396.  
  397. /img24 {
  398.    currentfile ImageRgbBuff readhexstring pop % read 3 bytes from the file
  399. } bd
  400.  
  401.  
  402. %----- normalised transfer function -----%
  403.  
  404. /normalise
  405. {
  406.   mark
  407.   1.0 1.0 .98 .9 .82 .68 
  408.   .56 .48 .28 .1 .06 .0                 % i [ nvalues
  409.   counttomark                           % i [ nvalues n
  410.   dup 3 add -1 roll exch                % [ nvalues input n
  411.   2 sub mul                             % [ nvalues j     % j = (n-2)*i k=floor(j)
  412.   dup floor cvi                         % [ nvalues j k
  413.   dup 3 1 roll sub                      % [ nvalues k j-k
  414.   exch dup                              % [ nvalues j-k k k
  415.   3 add index exch 2 add index dup      % [ nvalues j-k table[k+1] table[k] table[k]
  416.   4 1 roll                              % [ nvalues table[k] j-k table[k+1] table[k]
  417.   sub mul add                           % [ nvalues result    % result = ( table[k] + (j-k)*(table[k+1]-table[k]) )
  418.   counttomark 1 add 1 roll              % result [ nvalues
  419.   cleartomark                           % result
  420. } bd
  421.  
  422.  
  423. /?Negative {} bd % if printing negative, this procedure changes
  424.  
  425. /neg_transfer { 
  426.   /?Negative { 1 exch sub } bd 
  427.   {  ?Negative normalise DefTran } bind settransfer   
  428.   gs clippath 1 setgray fill gr              % then fill with white
  429.   
  430. } bd
  431.  
  432. %----- Special Effects: Flatten Path -----%
  433. %
  434. % flatten path, adjust 'setflat' until it works.
  435. % no parameters, no output. NOTE: this leaves a 'gs' in effect
  436.  
  437. /flatclip { 
  438.   currentflat
  439.   { 
  440.     gs
  441.     { flattenpath _clip } stopped not {exit}if
  442.     % ie, if not stopped due to error, exit loop
  443.     
  444.     % but if the error was other than limitcheck, stop now!
  445.     $error /errorname get /limitcheck ne { stop } if
  446.  
  447.     % if flatness gets too high, give up
  448.     currentflat 80 gt { exit } if
  449.     
  450.     % try again with flatter paths
  451.     gr currentflat 1.1 mul 1 add setflat
  452.   }loop
  453.   setflat
  454. } bd
  455.  
  456. /flatp { 
  457.   currentflat
  458.   { {flattenpath} stopped not {exit}if
  459.     currentflat 1 add setflat
  460.   }loop
  461.   setflat
  462. } bd
  463.  
  464.  
  465.  
  466. %----- Special Effects: Clip to Path -----%
  467. %
  468. % Also computes bounding box and width and height.
  469. % NOTE: flatclip saves graphics state
  470.  
  471. /clipper {
  472.   flatclip pathbbox 
  473.   /Bottom ed /Right ed /Top ed /Left ed
  474.   Right Left sub /Width ed
  475.   Bottom Top sub /Height ed
  476. } bd
  477.  
  478.  
  479.  
  480.  
  481. %----- Example of a special fill routine -----%
  482.  
  483. /examplefill {
  484.   clipper %gs implied
  485.     Left Top translate
  486.     % insert commands to fill area from (0,0) to (Width,Height)
  487.     Width Height scale
  488.     % or insert commands to fill unit square
  489.   gr
  490. } bd
  491.  
  492.  
  493.  
  494. %----- Graduated Fill Support Code -----%
  495.  
  496. /GradFillDict 30 dict def
  497.  
  498. /GrayProcs [ 
  499.   {} % 0: radial
  500.   {dup mul} bind % 1: spherical 
  501.   {} % 2
  502.   {} % 3: linear
  503.   {9 mul 1 add log} bind % 4: logarithmic
  504.   {dup 1 exch sub mul 4 mul} bind % 5: cylindrical 
  505. ] def
  506.  
  507. /grayconv { % start diff ingray GRAYCONV outgray 
  508.   GrayProcs GradType get exec
  509.   mul add
  510. } bd
  511.  
  512.  
  513. /grad_common_init {
  514.   %---- initialise variables in local dictionary
  515.  
  516.   % convert start colour to CMYK and get values
  517.   setcolour currentcmyk 
  518.   /StartK ed /StartY ed /StartM ed /StartC ed
  519.   /StartT SpotTint def
  520.  
  521.   % do the same for the end colour
  522.   setcolour currentcmyk
  523.   /EndK ed /EndY ed /EndM ed /EndC ed
  524.   /EndT SpotTint def 
  525.  
  526.   % replace End with End-Start
  527.   /EndC EndC StartC sub def
  528.   /EndM EndM StartM sub def
  529.   /EndY EndY StartY sub def
  530.   /EndK EndK StartK sub def
  531.   /EndT EndT StartT sub def
  532.  
  533.   % If printing colour separations, if the separation has
  534.   % the same tint for the start and end of the grad fill,
  535.   % treat it as a solid fill to save time.
  536.  
  537.   /SolidFill? F def
  538.  
  539.   Comp? not {           % not printing a composite - separations
  540.  
  541.     SpotSep? {          % printing a spot colour sep
  542.       StartT setgraytint
  543.       EndT 0 eq /SolidFill? ed
  544.     }{                  % printing a process sep
  545.       mark
  546.       StartC StartM StartY StartK 4 Separation roll
  547.       100 mul setgraytint % 0.22
  548.  
  549.       EndC EndM EndY EndK 4 Separation roll
  550.       0 eq /SolidFill? ed
  551.       
  552.       cleartomark
  553.     } ifelse
  554.  
  555.   } if
  556. } bd
  557.  
  558.  
  559. /grad_common_middle {
  560.   /X ed
  561.   SpotSep? {
  562.     StartT EndT X grayconv
  563.     setgraytint 
  564.   }{
  565.     StartC EndC X grayconv
  566.     StartM EndM X grayconv
  567.     StartY EndY X grayconv
  568.     StartK EndK X grayconv
  569.     setcmyk
  570.   } ifelse
  571. } bd
  572.  
  573.  
  574.  
  575.  
  576. %----- Graduated Fill: linear, logarithmic, cylindrical -----%
  577. %
  578. % parameters: angle type startcolour endcolour
  579. % each colour can be either a number (for a black tint)
  580. % a number and a name, or an array of four values: 
  581. % the same as setcolour.
  582. % type: 3=linear 4=logarithm 5=cylinder
  583.  
  584. /linfill {
  585.   GradFillDict begin
  586.   grad_common_init
  587.   /GradType ed
  588.   neg /Theta ed
  589.   /Steps GradType 3 ne { 100 } { 32 } ifelse def
  590.   % also uses Top Bottom Left Right Width Height in dictionary
  591.  
  592.   SolidFill? {
  593.  
  594.     ~fill       % separation, and fill is solid for this sep
  595.   }{
  596.  
  597.     %---- prepare to fill to clipping path 
  598.     %     and setup transformation matrix
  599.     gs
  600.       Theta rotate 
  601.       clipper %gs implied
  602.       Left Top translate
  603.       Width Height scale
  604.       1 Steps 1 add div setlinewidth
  605.  
  606.       0 1 Steps { 
  607.         dup Steps div
  608.  
  609.         grad_common_middle
  610.  
  611.         newpath
  612.           .5 add 
  613.           Steps 1 add 
  614.         div 0
  615.         moveto 
  616.  
  617.         0 1 rlineto
  618.         ~stroke
  619.  
  620.       } bind for
  621.     gr gr
  622.  
  623.   }ifelse
  624.  
  625.   end
  626. } bd
  627.  
  628.  
  629. %----- Radial/Spherical Graduated Fill -----%
  630. %
  631. % stack: type startcolour endcolour
  632. % type: 0=radial, 1=spherical
  633.  
  634. /radfill { 
  635.   GradFillDict begin
  636.   grad_common_init
  637.   /GradType ed
  638.   /Steps GradType 0 ne { 64 } { 32 } ifelse def
  639.  
  640.   SolidFill? {
  641.     ~fill       % separation, and fill is solid for this sep
  642.   }{
  643.  
  644.     clipper %gs implied
  645.       Left Right add 2 div Top Bottom add 2 div translate % centre
  646.       Width dup mul Height dup mul add sqrt 2 div dup scale % half diagonal
  647.       Steps -1 1 { % loop to fill unit circle centred on origin
  648.         /Rad exch Steps div def
  649.  
  650.         Rad grad_common_middle
  651.  
  652.         np 0 Rad moveto 0 0 Rad 0 360 arc cp
  653.         ~fill
  654.       } bind for
  655.     gr
  656.  
  657.   } ifelse
  658.  
  659.   end
  660. } bd
  661.  
  662. %----- Arrowheads -----------
  663.  
  664. /ArrowProcs [
  665. {} 
  666. {np 0 25 m 50 0 l 0 -25 l cp fill }
  667. {np 0 25 m 50 0 l 0 -25 l cp stroke }
  668. {np 0 0 m -10 25 l 50 0 l -10 -25 l cp fill }
  669. {np 0 0 m -10 25 l 50 0 l -10 -25 l cp stroke }
  670. {np -50 25 m 0 0 l -50 -25 l stroke }
  671. {np 0 25 m 0 -25 l stroke }
  672. {np 2 setlinejoin -50 25 m 0 0 l -50 -25 l 0 25 m 0 -25 l stroke }
  673. {np 50 25 m 0 0 l 50 -25 l stroke }
  674. {np 100 25 m 50 0 l 100 -25 l 50 0 m 0 0 l 50 25 m 0 0 l 50 -25 l stroke }
  675. {np 100 25 m 50 0 l 100 -25 l 45 -25 l -5 0 l 45 25 l cp fill }
  676. ] def
  677.  
  678. % type dx dy scale x y arrow
  679.  
  680. /arrow {
  681.   gs
  682.     translate 
  683.     dup 20 lt { pop 20 } if
  684.     10 div dup scale 
  685.     exch atan 180 add rotate
  686.     0 0 10 sline
  687.     Print? {
  688.       ArrowProcs exch get exec
  689.     }{
  690.       pop
  691.     } ifelse
  692.     gr
  693. } bd
  694.  
  695.  
  696.  
  697. %----- Tiled Fill -----------
  698.  
  699. /TiDict 20 dict def
  700.  
  701. /tipos {        % pos wid
  702.   dup           % pos wid wid
  703.   3 1 roll      % wid pos wid
  704.   div floor mul % pos'
  705. } bd
  706.  
  707. /_tile { % dx dy proc scaledwidth scaledheight scale(percent) angle
  708.   TiDict begin
  709.   /TiAngle ed 
  710.   100 div /Tscale ed
  711.   Tscale div /TiHgt ed 
  712.   Tscale div /TiWid ed 
  713.   /TiProc ed
  714.   % leave just dx & dy on stack
  715.  
  716.   gs 1 setgray ~fill gr % 0.18: fill shape with white
  717.  
  718.   gs
  719.     translate TiAngle neg rotate Tscale dup scale
  720.     flatclip pathbbox /TiBottom ed /TiRight ed /TiTop ed /TiLeft ed
  721.     TiTop TiHgt tipos TiHgt TiBottom {
  722.       gs 0 exch translate
  723.         TiLeft TiWid tipos TiWid TiRight {
  724.           gs 0 translate /TiProc load 
  725.           ArtVarsDict begin exec end gr
  726.         } for
  727.       gr
  728.     }for
  729.   gr gr
  730.   end
  731. } bd
  732.  
  733.  
  734. %--------- TEXT HANDLING -----------%
  735.  
  736.  /begintext { matrix currentmatrix } bd % leave current matrix on top of stack
  737.  /endtext { setmatrix } bd     % restore saved matrix
  738.  /ntm { exch dup setmatrix exch concat } bd % newtextmatrix: matrix
  739.  
  740.  
  741.  /textstyle { % proc
  742.   /SimpleText? F def
  743.   /filltext exch bind def
  744.  } bd
  745.  
  746.  /plaintext { % <colour & tint>
  747.   F ovp
  748.   setcolour
  749.   /SimpleText? T def
  750.  } bd
  751.  
  752. /tf { % textfont: size width fontname
  753.   findfont 3 1 roll
  754.   exch neg matrix scale makefont
  755.   setfont
  756. } bd
  757.  
  758. /txt { % x y string
  759.   3 1 roll moveto
  760.   SimpleText?
  761.   {
  762.     Print? { show } if
  763.   }{
  764.     {
  765.       currentpoint np moveto
  766.       tempstr 0 2 index put 
  767.       tempstr T charpath filltext
  768.       pop
  769.     } forall
  770.   } ifelse
  771. } bd
  772.  
  773. /filltext { } def
  774.  
  775.  
  776. /title { 
  777.   gs
  778.   moveto
  779.   {270 rotate} if
  780.   100 pt exch div dup neg scale
  781.   /Helvetica findfont 10 scalefont setfont
  782.   show
  783.   gr
  784. } bd
  785.  
  786. /regmark {
  787.   gs translate 
  788.   1 setlinewidth
  789.   np -100 0 moveto 100 0 lineto stroke
  790.   np 0 -100 moveto 0 100 lineto stroke
  791.   np 0 0 50 0 360 arc stroke
  792.   gr
  793. } bd
  794.  
  795. /cropmark {
  796.   gs 1 setlinewidth np moveto lineto stroke gr
  797. } bd
  798.  
  799. %----- Routines to rearrange font to match Windows Ansi character set -----%
  800.  
  801. /ANSI_Vec [
  802.  /grave/acute/circumflex/tilde/macron/breve/dotaccent/dieresis
  803.  /ring/cedilla/hungarumlaut/ogonek/caron/dotlessi/.notdef/.notdef
  804.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  805.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  806.  /space/exclam/quotedbl/numbersign/dollar/percent/ampersand/quotesingle
  807.  /parenleft/parenright/asterisk/plus/comma/hyphen/period/slash
  808.  /zero/one/two/three/four/five/six/seven
  809.  /eight/nine/colon/semicolon/less/equal/greater/question
  810.  /at/A/B/C/D/E/F/G
  811.  /H/I/J/K/L/M/N/O
  812.  /P/Q/R/S/T/U/V/W
  813.  /X/Y/Z/bracketleft/backslash/bracketright/asciicircum/underscore
  814.  /grave/a/b/c/d/e/f/g
  815.  /h/i/j/k/l/m/n/o
  816.  /p/q/r/s/t/u/v/w
  817.  /x/y/z/braceleft/bar/braceright/asciitilde/.notdef
  818.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  819.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  820.  /.notdef/quoteleft/quoteright/quotedblleft/quotedblright/bullet/endash/emdash
  821.  /.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef/.notdef
  822.  /space/exclamdown/cent/sterling/currency/yen/brokenbar/section
  823.  /dieresis/copyright/ordfeminine/guillemotleft/logicalnot/hyphen/registered/macron
  824.  /degree/plusminus/twosuperior/threesuperior/acute/mu/paragraph/periodcentered
  825.  /cedilla/onesuperior/ordmasculine/guillemotright/onequarter/onehalf/threequarters/questiondown
  826.  /Agrave/Aacute/Acircumflex/Atilde/Adieresis/Aring/AE/Ccedilla
  827.  /Egrave/Eacute/Ecircumflex/Edieresis/Igrave/Iacute/Icircumflex/Idieresis
  828.  /Eth/Ntilde/Ograve/Oacute/Ocircumflex/Otilde/Odieresis/multiply 
  829.  /Oslash/Ugrave/Uacute/Ucircumflex/Udieresis/Yacute/Thorn/germandbls
  830.  /agrave/aacute/acircumflex/atilde/adieresis/aring/ae/ccedilla
  831.  /egrave/eacute/ecircumflex/edieresis/igrave/iacute/icircumflex/idieresis
  832.  /eth/ntilde/ograve/oacute/ocircumflex/otilde/odieresis/divide 
  833.  /oslash/ugrave/uacute/ucircumflex/udieresis/yacute/thorn/ydieresis
  834. ] def
  835.  
  836.  
  837. /ReEncDict 12 dict def
  838.  
  839. /ischar {
  840.   BaseFontDict /CharStrings get exch known
  841. }bd
  842.  
  843. /mapch {
  844.   dup ischar not 
  845.   {pop /.notdef} if 
  846.   NewFont /Encoding get 3 1 roll put 
  847. }bd
  848.  
  849. /mapdegree{ 16#b0 /degree ischar {/degree}{/ring} ifelse mapch } bd
  850.  
  851. /mapbb { 16#a6 /brokenbar ischar {/brokenbar}{/bar}ifelse mapch } bd
  852.  
  853. /reencoderange {  
  854.   { dup ANSI_Vec exch get mapch } for
  855. } bd
  856.  
  857. /reencode {
  858.   0 1 15 reencoderange
  859.   160 1 255 reencoderange
  860.   16#27 /quotesingle mapch
  861.   16#60 /grave mapch
  862.   16#7C /bar mapch
  863.   mapdegree mapbb
  864. } bd
  865.  
  866. /ansifont {
  867.  ReEncDict begin
  868.    /NewFontName exch def 
  869.    /BaseFontName exch def
  870.    FontDirectory NewFontName known not
  871.    {
  872.      /BaseFontDict BaseFontName findfont def
  873.      /NewFont BaseFontDict maxlength dict def
  874.      BaseFontDict {
  875.        exch dup /FID ne { 
  876.          dup /Encoding eq { 
  877.            exch 
  878.            dup length array copy 
  879.            NewFont 3 1 roll put 
  880.          }{ 
  881.            exch 
  882.            NewFont 3 1 roll put 
  883.          }
  884.          ifelse
  885.        }{
  886.          pop pop
  887.        }ifelse
  888.      }forall
  889.      NewFont /FontName NewFontName put
  890.  
  891.      % look at the charstrings see if it has 'A' and 'Z':
  892.      % if so, remap the font. If not, leave it alone!
  893.      /A ischar /Z ischar and { reencode } if
  894.      NewFontName NewFont definefont pop
  895.    } if
  896.    NewFontName
  897.  end
  898. } bind def
  899.  
  900.  
  901. %----- Colour Separation Setup Procedures -----%
  902. %
  903. % Separation: if undefined, a composite is produced
  904. %       if numeric, a process colour separation is produced
  905. %               3=cyan, 2=magenta, 1=yellow, 0=black
  906. %       if a name of a spot colour, that spot separation is produced
  907. %
  908. % example:
  909. %       /Separation 3 def setupsep 
  910. %       /Separation /Reflex_Blue def setupsep
  911.  
  912.  
  913. /setupsep {
  914.   /Separation where {           % is 'Separation' defined?
  915.     pop
  916.     /Comp? F def                % yes: we're doing a separation.
  917.     Separation type             % is it a number?
  918.     0 type ne 
  919.     /SpotSep? ed          % if not, we're doing a spot colour.
  920.   }{
  921.     /Comp? T def                % separation not defined: doing a composite.
  922.     /SpotSep? F def
  923.   } ifelse
  924.  
  925.   statusdict begin Timeout setjobtimeout end % timeout per separation
  926.  
  927. } bd
  928.  
  929.  
  930. /setsepscreen { AngleFix add /DefScrFun load setscreen } bd
  931.  
  932.  
  933. %---------- included EPSF procedure
  934.  
  935. /include_epsf {
  936.   /Bottom ed /Left ed 
  937.   gsave concat
  938.  
  939.   % assumes that bottom-left of rect corresponds to EPSF's origin
  940.   Left Bottom translate
  941.   1000 72 div dup neg scale
  942.  
  943.   /EpsfSave save def
  944.  
  945.   /showpage { } def
  946.  
  947.   currentfile cvx stopped { % did it stop?
  948.     $error /newerror get {  % was it a new error?
  949.       handleerror           % put out an error message
  950.  
  951.       % skip to end of included file
  952.       { % loop
  953.         currentfile LineBuff readline {
  954.           (\045\045EndEPSF) eq { exit } if
  955.         }{
  956.           % can't find end marker - hit EOF?
  957.         } ifelse
  958.       } loop
  959.  
  960.     } if
  961.   }{
  962.     % didn't stop - hit EOF?
  963.   } ifelse
  964.   $error /newerror F put
  965.  
  966.   EpsfSave restore
  967.   grestore
  968. } bd
  969.  
  970. %--------------------------------- downloaded font stuff -------------------
  971.  
  972. /BuildDict 3 dict def
  973.  
  974. /PointProcs[{}{closepath moveto}bind/lineto load/curveto load]def
  975.  
  976. /gst_char { n 8 bitshift add /n ed /i i 1 add def
  977. i 3 eq {
  978.   n 2047 and dup 1600 gt { 2048 sub } if
  979.   n -11 bitshift 2047 and dup 1600 gt { 2048 sub } if
  980.   n -22 bitshift 3 and PointProcs exch get exec
  981.   /n 0 def /i 0 def
  982.   } if
  983. } bd
  984.  
  985. /gst_build { 
  986. exch begin 
  987.   BuildDict begin 
  988.     Encoding exch get 
  989.     /n 0 def /i 0 def
  990.     dup Metrics exch get 0 setcharwidth 
  991.     newpath CharStrings exch get { gst_char } forall 
  992.     closepath fill 
  993.   end 
  994. end
  995. } bd
  996.  
  997. /gst_fast { 
  998. exch begin 
  999.   Encoding exch get 
  1000.   dup Metrics exch get 0 setcharwidth 
  1001.   CharStrings exch get cvx exec 
  1002. end
  1003. } bd
  1004.  
  1005. /newgstfont {
  1006.   ReEncDict begin
  1007.   /NewFontSize ed
  1008.   /NewFontId ed
  1009.   /NewFontFast ed
  1010.   /NewFontName ed
  1011.   10 dict dup begin
  1012.     /FontMatrix [ .001 0 0 .001 0 0 ] def
  1013.     /FontType 3 def
  1014.     /FontBBox [ -400 -300 1600 1000 ] def
  1015.     /Encoding ANSI_Vec def
  1016.     /Metrics NewFontSize dict def Metrics /.notdef 0 put
  1017.     /CharStrings NewFontSize dict def CharStrings /.notdef () put
  1018.     /UniqueID 16#ff0000 NewFontId add def
  1019.     /gst_fast /gst_build NewFontFast { exch } if load /BuildChar ed pop
  1020.   end
  1021.   NewFontName exch definefont pop
  1022.   NewFontName
  1023. end
  1024. } bd
  1025.     
  1026. /NewCharDict 4 dict def
  1027.  
  1028. /newchar { 
  1029. NewCharDict begin
  1030.   /Proc ed
  1031.   /Wid ed
  1032.   /Code ed
  1033.   dup findfont begin
  1034.     Encoding Code get dup
  1035.     CharStrings exch /Proc load put
  1036.     Metrics exch Wid put
  1037.   end
  1038. end
  1039. } bd
  1040.  
  1041.  
  1042. %%EndProlog
  1043.  
  1044. %%BeginSetup
  1045.  
  1046. /ArtworkSave save def
  1047.   ArtVarsDict begin
  1048.  
  1049.   % boolean abbreviations
  1050.   /T true def /F false def
  1051.  
  1052.   % initialise default line end, join, mitre limit etc
  1053.   1 1 14 sline 10 sml
  1054.  
  1055.   % initialise misc variables
  1056.   /tempstr 1 string def         % buffer for text
  1057.   /ImageBuff 1 string def       % buffer for bitmap images
  1058.   /ImageRgbBuff 3 string def    % buffer for bitmap images
  1059.   /LineBuff 256 string def      % buffer for included epsfs
  1060.   /SimpleText? T def            % flag for fast text handling
  1061.   /Wind? T def                  % winding fill on/off
  1062.   /Print? T def                 % print flag used by colour separation stuff
  1063.   /SaveCmyk 4 array def         % current C,M,Y,K colour
  1064.   /Imat matrix identmatrix def  % an indentity matrix
  1065.   /bignum 2 31 exp 1 sub def    % for random number generator
  1066.   initcmykcolor
  1067.  
  1068.   % determine current transformation's rotation, (eg for landscape)
  1069.   % which will need to be applied to any screen angles
  1070.   /AngleFix 1 0 dtransform exch atan def
  1071.  
  1072.   % record the current screen function, angle and frequency
  1073.   currentscreen /DefScrFun exch def pop pop
  1074.   ArtProcsDict /Screens known {
  1075.     currentscreen Screens exch 0 exch put pop pop
  1076.   } if
  1077.  
  1078.   % record the current transfer function, and set up a normalised
  1079.   % transfer function followed by the default
  1080.   /DefTran currenttransfer def
  1081.   {normalise DefTran}bind settransfer
  1082.  
  1083.  
  1084. %%EndSetup
  1085.  
  1086. %%Trailer
  1087. end % ArtVarsDict
  1088. ArtworkSave restore
  1089. end % ArtProcsDict
  1090. %%EOF
  1091.  
  1092.  
  1093.